import { ref, getCurrentInstance } from "vue"

export default function() {
// export default {
  // setup() {
    const isLoading = ref(false)
    const loaded = ref(false)
    const perPage = ref(10)
    const currentPage = ref(1)
    const total = ref(0)
    const proxy = getCurrentInstance() ? getCurrentInstance().proxy : null
    // const { $http, $util } = getCurrentInstance().appContext.config.globalProperties

    // const page = reactive({
    //   // 每页多少数据
    //   perPage: 10,
    //   // 当前页
    //   currentPage: 1,
    //   // 总条数
    //   total: 0
    // })

    const startLoading = () => {
      isLoading.value = true
    }

    const stopLoading = () => {
      isLoading.value = false
      loaded.value = true
    }

    return {
      isLoading,
      loaded,
      perPage,
      currentPage,
      total,
      startLoading,
      stopLoading,
      proxy,
      // $http,
      // $util
    }
  // },
}
